<template>
  <div>
    <!--header start-->
    <header :class="['header-con','header-w-bg']">
      <router-link to='/membercenter'>
        <a>
          <i class='back-icon'></i>
        </a>
      </router-link>
      <h1 class='header-tit'>专属旅游顾问</h1>
    </header>
    <!--header end-->
    <!--content start-->
    <div class="consultant-page hasBind">
      <img :src="consultantInfo.content.imgStr == '' ? 'http://paytest.ecwalk.com/static/images/mobileImages/consultant.png' : consultantInfo.content.imgStr" alt="">
      <div class="consultant-message">
        <h2>{{consultantInfo.content.realName}}</h2>
        <ul class="flex-box">
          <li>
            <p>职务</p>
            <div>{{consultantInfo.content.govJob}}</div>
          </li>
          <li>
            <p>门店</p>
            <div>{{consultantInfo.content.orgName}}</div>
          </li>
          <li>
            <p>邀请码</p>
            <div>{{consultantInfo.content.recommendCode}}</div>
          </li>
        </ul>
      </div>
    </div>
    <!--content end-->
    <div class="footer-con">
      <span><a>电话联系我</a></span>
    </div>
  </div>
</template>

<script>
  import axios from 'axios'
  import qs from 'qs'
  import weui from 'weui.js'
  import common from '../../assets/js/common'
  export default {
    data () {
      return {
        consultantInfo: {
          'resultCode': '',
          'resultMsg': '',
          'content': {
            'realName': '',
            'govJob': '',
            'govOrg': '',
            'recommendCode': '',
            'mobile': '',
            'imgStr': '',
            'orgName': ''
          },
          'accessToken': null
        },
        recommendCode: ''
      }
    },
    created: function () {
      var self = this
      self.recommendCode = self.$route.params.recommendCode
      self.getUserInfo()
    },
    methods: {
      getUserInfo: function () {
        var self = this
        var queryUrl = common.api.memberCenter.getUserByRecomCode
        var config = {
          headers: {
            'access-token': common.accesstoken,
            'Content-Type': 'application/x-www-form-urlencoded'
          }
        }
        var data = qs.stringify({
          recommendCode: self.recommendCode
        })
        var loading = weui.loading('加载中')
        axios.post(queryUrl, data, config).then(function (res) {
          console.log(res)
          if (res.data.resultMsg === 'success') {
            self.consultantInfo = res.data
            loading.hide()
          } else {
            loading.hide()
            weui.toast('请求失败')
          }
        })
      }
    }
  }
</script>

<style lang="scss">
 @import '../../assets/sass/member/tripConsultant';
</style>
